package homeadapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.yztc.thinkpad.mandemo.R;

import java.util.List;

import homebean.HomevpBean;

/**
 *首页的 GrideView加载每日签到的文字和图片
 * Created by Administrator on 2016/10/7.
 */
public class GrideViewAdapter extends BaseAdapter {
    private Context context;
    private List<HomevpBean.DataBean> mList;
    public GrideViewAdapter(Context context, List<HomevpBean.DataBean> mList) {
        this.context = context;
        this.mList = mList;
    }
    @Override
    public int getCount() {
        return 4;
    }

    @Override
    public Object getItem(int i) {
        return mList.get(i+6);
    }

    @Override
    public long getItemId(int i) {
        return i+6;
    }
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder mViewHolder;
        if (view==null){
            view= LayoutInflater.from(context).inflate(R.layout.home_grivde_item,null);
            mViewHolder=new ViewHolder();
            mViewHolder.iv_gv_item= (ImageView) view.findViewById(R.id.iv_gv_item);
            mViewHolder.tv_gv_item= (TextView) view.findViewById(R.id.tv_gv_item);
            view.setTag(mViewHolder);
        }else{
            mViewHolder= (ViewHolder) view.getTag();
        }
        mViewHolder.tv_gv_item.setText(mList.get(i+6).getTheme_name());
        Glide.with(context).load(mList.get(i+6).getTheme_image()).into(mViewHolder.iv_gv_item);
        return view;
    }
    static  class ViewHolder{
        ImageView iv_gv_item;
        TextView  tv_gv_item;
    }
}
